package com.jic.market.common.enums;

import java.util.EnumSet;

/**
 * @author : xuyongliang
 * @date : 2020/3/16
 * @description: 是否成本分摊 0否 1是
 * @modified By:
 * @version: V1.0
 */
public enum CostAllocationFlagEnum {

    // 是否成本分摊 0否 1是
    NO_SHARE("0", "否"),
    SHARE("1", "是"),
    ;

    private String code;

    private String value;

    CostAllocationFlagEnum(String code, String value) {
        this.code = code;
        this.value = value;
    }

    public static CostAllocationFlagEnum getEnumByCode(String code){
        EnumSet<CostAllocationFlagEnum> elements = EnumSet.allOf(CostAllocationFlagEnum.class);
        for(CostAllocationFlagEnum enumType : elements){
            if(enumType.getCode().equals(code)){
                return enumType;
            }
        }
        return null;
    }

    public static String getCodeByValue(String value) {
        for (CostAllocationFlagEnum c : CostAllocationFlagEnum.values()) {
            if (c.getValue().equals(value.trim())) {
                return c.getCode();
            }
        }
        return null;
    }

    public static String getValue(String code) {
        return getEnumByCode(code).getValue();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
